package com.cykj.pos.util.epse;

import com.cykj.pos.domain.epsp.Response;
import com.cykj.pos.domain.epsp.WechatH5.WechatH5Request;
import com.cykj.pos.domain.epsp.WechatH5.WechatH5Response;
import com.cykj.pos.domain.epsp.account.BalancePaymentRequest;
import com.cykj.pos.domain.epsp.account.BalancePaymentResponse;
import com.cykj.pos.domain.epsp.aliJSAPI.AliJSAPIRequest;
import com.cykj.pos.domain.epsp.aliJSAPI.AliJSAPIResponse;
import com.cykj.pos.domain.epsp.authentication.AuthenticationRequest;
import com.cykj.pos.domain.epsp.authentication.AuthenticationResponse;
import com.cykj.pos.domain.epsp.cancel.CancelApplyRequest;
import com.cykj.pos.domain.epsp.cancel.CancelApplyResponse;
import com.cykj.pos.domain.epsp.cashierPay.CashierRequest;
import com.cykj.pos.domain.epsp.cashierPay.CashierResponse;
import com.cykj.pos.domain.epsp.close.CloseApplyRequest;
import com.cykj.pos.domain.epsp.close.CloseApplyResponse;
import com.cykj.pos.domain.epsp.memberEnter.MemberEnterRequest;
import com.cykj.pos.domain.epsp.memberEnter.MemberEnterResponse;
import com.cykj.pos.domain.epsp.microPay.MicroPayRequest;
import com.cykj.pos.domain.epsp.microPay.MicroPayResponse;
import com.cykj.pos.domain.epsp.nativePay.NativePayRequest;
import com.cykj.pos.domain.epsp.nativePay.NativePayResponse;
import com.cykj.pos.domain.epsp.other.TerminalQuery_Response;
import com.cykj.pos.domain.epsp.other.TerminalQuery_request;
import com.cykj.pos.domain.epsp.other.Terminal_Response;
import com.cykj.pos.domain.epsp.other.Terminal_request;
import com.cykj.pos.domain.epsp.paymenQuery.PaymentQueryRequest;
import com.cykj.pos.domain.epsp.paymenQuery.PaymentQueryResponse;
import com.cykj.pos.domain.epsp.protocol.*;
import com.cykj.pos.domain.epsp.refund.RefundApplyRequest;
import com.cykj.pos.domain.epsp.refund.RefundApplyResponse;
import com.cykj.pos.domain.epsp.refundQuery.RefundApplyQueryRequest;
import com.cykj.pos.domain.epsp.refundQuery.RefundApplyQueryResponse;
import com.cykj.pos.domain.epsp.split.*;
import com.cykj.pos.domain.epsp.split.relation.*;
import com.cykj.pos.domain.epsp.splitRefund.RefundRequest;
import com.cykj.pos.domain.epsp.splitRefund.RefundResponse;
import com.cykj.pos.domain.epsp.transfer.TransferPayRequest;
import com.cykj.pos.domain.epsp.transfer.TransferPayResponse;
import com.cykj.pos.domain.epsp.union.UnionPayRequest;
import com.cykj.pos.domain.epsp.union.UnionPayResponse;
import com.cykj.pos.domain.epsp.wechatJSAPI.WechatJSAPIRequest;
import com.cykj.pos.domain.epsp.wechatJSAPI.WechatJSAPIResponse;
import com.cykj.pos.domain.epsp.withdraw.*;

import java.util.Map;


public class PaymentHelper {

    /**
     * 支付宝服务窗支付
     * @param request 订单内容
     * @throws Exception
     */
    public static AliJSAPIResponse aliJSAPIPay(AliJSAPIRequest request) throws Exception{
    	System.out.println( Config.getAliJSAPIUrl());
        return RemoteInvoker.invoke(request, Config.getAliJSAPIUrl(), AliJSAPIResponse.class);
    }

    /**
     * 微信公众号支付
     * @param request 订单内容
     * @throws Exception
     */
    public static WechatJSAPIResponse wechatJSAPIPay(WechatJSAPIRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWechatJSAPIUrl(), WechatJSAPIResponse.class);
    }

    /**
     * 微信H5支付
     * @param request 订单内容
     * @throws Exception
     */
    public static WechatH5Response wechatH5Pay(WechatH5Request request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWechatH5Url(), WechatH5Response.class);
    }

    /**
     * 主扫支付
     * @param request 订单内容
     * @throws Exception
     */
    public static NativePayResponse nativePay(NativePayRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getNativePayUrl(), NativePayResponse.class);
    }

    /**
     * 被扫支付
     * @param request 订单内容
     * @throws Exception
     */
    public static MicroPayResponse microPay(MicroPayRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getScaningURL(), MicroPayResponse.class);
    }

    /**
     * 预下单支付/收银台支付
     * @param request 订单内容
     * @throws Exception
     */
    public static CashierResponse cashierPay(CashierRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getCashierPayUrl(), CashierResponse.class);
    }

    /**
     * 支付结果查询
     * @param request 订单内容
     * @throws Exception
     */
    public static PaymentQueryResponse paymentQuery(PaymentQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getPaymentQueryUrl(), PaymentQueryResponse.class);
    }
    //------------------退款----------------
    /**
     * 退款申请
     * @param request 订单内容
     * @throws Exception
     */

    public static RefundApplyResponse refundApply(RefundApplyRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundApplyUrl(), RefundApplyResponse.class);
    }

    /**
     * 退款查询
     * @param request 订单内容
     * @throws Exception
     */
    public static RefundApplyQueryResponse refundQuery(RefundApplyQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundQueryUrl(), RefundApplyQueryResponse.class);
    }
    /**
     * 退款查询
     * @param request 订单内容
     * @throws Exception
     */
    public static RefundApplyQueryResponse refundOrderQuery(RefundApplyQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundOrderQueryUrl(), RefundApplyQueryResponse.class);
    }
    /**
     * 退款
     * @param request 订单内容
     * @throws Exception
     */
    public static RefundResponse refund(RefundRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getRefundUrl(), RefundResponse.class);
    }

    //------------------分账----------------
    /**
     * 分账
     * @param request 订单内容
     * @throws Exception
     */
    public static SplitResponse split(SplitRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitPayUrl(), SplitResponse.class);
    }
    /**
     * 账户分账
     * @param order 订单内容
     * @throws Exception
     */
    public static accountSplitResponse accountSplit(accountSplitRequest order) throws Exception{
        return RemoteInvoker.invoke(order, Config.getAccountSplitPayUrl(), accountSplitResponse.class);
    }
    /**
     * 账户分账确认
     * @param order 订单内容
     * @throws Exception
     */
    public static accountSplitConfirmResponse accountSplitConfirm(accountSplitConfirmRequest order) throws Exception{
        return RemoteInvoker.invoke(order, Config.getAccountSplitConfirmPayUrl(), accountSplitConfirmResponse.class);
    }
    /**
     * 分账查询
     * @param request 订单内容
     * @throws Exception
     */
    public static SplitResultQueryResponse splitResultQuery(SplitResultQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitResultQueryURL(), SplitResultQueryResponse.class);
    }
    //------------------提现----------------
    /**
     * 会员提现
     * @param request 订单内容
     * @throws Exception
     */
    public static Withdraw4SubMerchantResponse withdraw4member(MemberWithdrawRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdraw4Member(), Withdraw4SubMerchantResponse.class);
    }

    /**
     * 子商户提现
     * @param request 订单内容
     * @throws Exception
     */
    public static Withdraw4SubMerchantResponse withdraw4SubMerchant(Withdraw4SubMerchantRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdraw4SubMerchantUrl(), Withdraw4SubMerchantResponse.class);
    }
    /**
     * 子商户提现查询
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawQuery4SubMerchantResponse withdrawQuery4SubMerchant(WithdrawQuery4SubMerchantRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawQuery4SubMerchantUrl(), WithdrawQuery4SubMerchantResponse.class);
    }
    /**
     * 单笔代付
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawToCardResponse withdrawalToCard(WithdrawToCardRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawalToCardUrl(), WithdrawToCardResponse.class);
    }

    /**
     * 网银支付
     * @param request 订单内容
     * @throws Exception
     */
    public static UnionPayResponse unionPay(UnionPayRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getUnionPayUrl(), UnionPayResponse.class);
    }

    /**
     * 单笔代付查询
     * @param request 订单内容
     * @throws Exception
     */
    public static WithdrawToCardQueryResponse withdrawalToCardQuery(PaymentQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getWithdrawalToCardQueryUrl(), WithdrawToCardQueryResponse.class);
    }

    /**
     * 余额查询
     * @param request 订单内容
     * @throws Exception
     */
    public static CustomerAccountQueryResp accountQuery(Map<String, String> request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getAccountQueryUrl(), CustomerAccountQueryResp.class);
    }
    /**
     * 商户收支明细查询
     * @param request 订单内容
     * @throws Exception
     */
    public static Response customerQueryAccountFlow(Map<String, String> request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getCustomerQueryAccountFlowUrl(), Response.class);
    }


    /**
     * 协议支付绑卡预交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardResponse bindCard(ProtocolPayBindCardRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getBindCardUrl(), ProtocolPayBindCardResponse.class);
    }

    /**
     * 协议支付绑卡确认
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardConfirmResponse bindCardConfirm(ProtocolPayBindCardConfirmRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getBindCardConfirmUrl(), ProtocolPayBindCardConfirmResponse.class);
    }
    /**
     * 协议支付前台绑卡
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayFrontBindCardResponse frontBindCard(ProtocolPayFrontBindCardRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getFrontBindCardUrl(), ProtocolPayFrontBindCardResponse.class);
    }
    /**
     * 协议支付预交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayResponse protocolPayPre(ProtocolPayRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolPayPreUrl(), ProtocolPayResponse.class);
    }

    /**
     * 协议支付确认交易
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayConfirmResponse protocolPayConfirm(ProtocolPayConfirmRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolPayConfirmUrl(), ProtocolPayConfirmResponse.class);
    }

    /**
     * 协议支付解绑
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolPayBindCardResponse unBindCard(ProtocolPayUnbindCardRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getUnBindCardUrl(), ProtocolPayBindCardResponse.class);
    }

    /**
     * 协议查询
     * @param request 订单内容
     * @throws Exception
     */
    public static ProtocolQueryResponse protocolQuery(ProtocolQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getProtocolQuery(), ProtocolQueryResponse.class);
    }

    /**
     * 银行卡鉴权
     * @param order 订单内容
     * @throws Exception
     */
    public static AuthenticationResponse authentication(AuthenticationRequest order) throws Exception{
        return RemoteInvoker.invoke(order, Config.getAuthenticationUrl(), AuthenticationResponse.class);
    }


    /**
     * 撤销订单
     * @param order 撤销订单
     * @throws Exception
     */
    public static CancelApplyResponse cancel(CancelApplyRequest order) throws Exception{
        return RemoteInvoker.invoke(order, Config.getCancelApplyUrl(), CancelApplyResponse.class);
    }

        /**
     * 关闭订单
     * @param order 撤销订单
     * @throws Exception
     */
    public static CloseApplyResponse close(CloseApplyRequest order) throws Exception{
        return RemoteInvoker.invoke(order, Config.getCloseApplyUrl(), CloseApplyResponse.class);
    }
    /**
     * 分账关系创建
     * @param request 分账关系创建
     * @throws Exception
     */
    public static SplitRelationResponse splitRelationAdd(SplitRelationAddRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationAddUrl(), SplitRelationResponse.class);
    }
    /**
     * 分账关系查询
     * @param request 分账关系查询
     * @throws Exception
     */
    public static SplitRelationQueryResponse splitRelationQuery(SplitRelationQueryRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationQueryUrl(), SplitRelationQueryResponse.class);
    }
    /**
     * 分账关系修改
     * @param request 分账关系修改
     * @throws Exception
     */
    public static SplitRelationResponse splitRelationUpdate(SplitRelationUpdateRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getSplitRelationUpdateUrl(), SplitRelationResponse.class);
    }
    /**
     * 分账子商户入驻
     * @param request 分账子商户入驻
     * @throws Exception
     */
    public static MemberEnterResponse memberEnter(MemberEnterRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getMemberEnterUrl(), MemberEnterResponse.class);
    }
    /**
     *
     * @param request 终端信息报备
     * @throws Exception
     */
    public static Terminal_Response Terminal_request(Terminal_request request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getTerminalTermInUrl(), Terminal_Response.class);
    }
    /**
     *
     * @param request 终端信息查询
     * @throws Exception
     */
    public static TerminalQuery_Response Terminal_query(TerminalQuery_request request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getTerminalQueryUrl(), TerminalQuery_Response.class);
    }
    /**
     *
     * @param request 转账支付
     * @throws Exception
     */
	public static TransferPayResponse TransferPayment(TransferPayRequest request) throws Exception {
		// TODO Auto-generated method stub
		 return RemoteInvoker.invoke(request, Config.getTransferPayUrl(), TransferPayResponse.class);

	}
	/**
     *
     * @param request 个人账户消费
     * @throws Exception
     */
    public static BalancePaymentResponse BalancePayment(BalancePaymentRequest request) throws Exception{
        return RemoteInvoker.invoke(request, Config.getBalancePaymentUrl(), BalancePaymentResponse.class);
    }


}

